package com.qfedu.controller;

import com.qfedu.pojo.req.Cart;
import com.qfedu.pojo.req.CartItem;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.service.CartItemService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author:User
 * @time:2022/9/28
 * @explain:
 */
@RestController
@RequestMapping("/cartItem")
public class CartItemServlet {

    @Autowired
    private CartItemService cartItemService;

    /**
     * 商品的个数添加
     */
    @PostMapping  ("/addItem")
    public BaseResp addCartItem(@RequestBody CartItem cartItem,HttpSession session) {

        return cartItemService.addItem(cartItem,session);


    }

    /**
     * 商品的个数减少
     * @return
     */
    @PutMapping ("/subtractItem")
    public BaseResp subtractItem(@RequestBody CartItem cartItem,HttpSession session){
        BaseResp baseResp = cartItemService.subtractItem(cartItem, session);
        return baseResp;
    }
}
